import request from "@/utils/request";

// 获取类型businessType
function getBusinessType() {
  let type = "";
  const pathname = window.location.pathname;
  if (pathname.includes("allNotice")) {
    type = "ALL";
  }
  if (pathname.includes("departmentNotice")) {
    type = "DEPART";
  }
  return type;
}

// 通知公告列表
export const getNoticePages = (data) => {
  const type = getBusinessType();
  return request({
    url: `/workflow/notice_info/pages/${type}`,
    method: "post",
    data,
  });
};
// 通知公告--基本信息查询
export const getNoticeInfo = (params) => {
  const type = getBusinessType();
  return request({
    url: `/workflow/notice_info/info/${type}`,
    method: "GET",
    params,
  });
};

// 查询--基本信息
export const getauditInfo = (params) => {
  const type = getBusinessType();
  return request({
    url: `/workflow/audit/info/${type}`,
    method: "GET",
    params,
  });
};

// 我审批的---基本信息查询
export const gettaskInfo = (params) => {
  const type = getBusinessType();
  return request({
    url: `/workflow/task_info/info/${type}`,
    method: "GET",
    params,
  });
};
// 新建
export const save = (operateType, data) => {
  const type = getBusinessType();
  return request({
    url: `/workflow/audit/save/${operateType}/${type}`,
    method: "POST",
    data,
  });
};

// 全委通知----我创建的
export const getICreatList = (data) => {
  const type = getBusinessType();
  return request({
    url: `/workflow/audit/list/${type}`,
    method: "POST",
    data,
  });
};

// 阅读情况列表
// export const readList = (data) => {
//   const type = getBusinessType();
//   return request({
//     url: `/workflow/notice_info/pages/${type}`,
//     method: "POST",
//     data,
//   });
// };
export const readList = (data) => {
  const type = getBusinessType();
  return request({
    url: `/workflow/notice_info/read_status/pages/${type}`,
    method: "POST",
    data,
  });
};
// 全委通知 -- 我创建的 --撤回
export const creatReback = (data) => {
  return request({
    url: `/workflow/audit/reback`,
    method: "POST",
    data,
  });
};

// 全委通知 --通知公告--基本信息查询
export const setReadStatus = (data) => {
  return request({
    url: "/workflow/notice_info/update/read_status",
    method: "POST",
    data,
  });
};

// 全委通知----我审批的
export const getIapproveList = (data) => {
  const type = getBusinessType();
  return request({
    url: `/workflow/taskinfo/pages/${type}`,
    method: "POST",
    data,
  });
};

// 详情查询
export const getOapproveDetail = (params) => {
  const type = getBusinessType();
  return request({
    url: `/workflow/taskinfo/info/${type}`,
    method: "GET",
    params,
  });
};
// 审批--提交审批意见
export const getMessage = (operateType, data) => {
  const type = getBusinessType();
  return request({
    url: `/workflow/taskinfo/save/${operateType}/${type}`,
    method: "POST",
    data,
  });
};

// 删除
export const delBatch = (data) => {
  return request({
    url: `/workflow/audit/delete_batch_ids`,
    method: "POST",
    data,
  });
};
